#include <stdio.h>
#include <stdlib.h>
#include <csp_spu.h>
#include <csp_debug.h>


int dot_data_values[] = {100, 101, 102, 103, 104, 105, 106, 107, 108, 109};
int dot_data_size = 10;
int global_pid;

int Run(){
	int i;
	int pid = csp_pid();
	global_pid = csp_pid();
	#ifndef CLEAR_SPE_MEM
	PRINTF_FOR_TESTING("Must be compiled with -DCLEAR_SPE_MEM\n");
	ASSERT(0);
	#endif
	PRINTF_FOR_TESTING("Process running with pid=%d on spe #%d - yielding...\n", pid, csp_spe_id());

	PRINTF_FOR_TESTING("Before yield: { ");
	for(i = 0; i < dot_data_size; i++){
		PRINTF_FOR_TESTING("%i ", dot_data_values[i]);
		ASSERT((i+100) == dot_data_values[i]);	
		dot_data_values[i] += 100;
	}
	PRINTF_FOR_TESTING("}\n");

	csp_yield();
	
	PRINTF_FOR_TESTING("After yield: { ");
	for(i = 0; i < dot_data_size; i++){
		PRINTF_FOR_TESTING("%i ", dot_data_values[i]);
		ASSERT((i+200) == dot_data_values[i]);	
	}
	PRINTF_FOR_TESTING("}\n");


	ASSERT( pid == csp_pid() );
	ASSERT( global_pid == csp_pid() );

	PRINTF_FOR_TESTING("Terminating with pid=%d on spe #%d.\n", csp_pid(), csp_spe_id());

	return 0;
}

